<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <title>Title</title>
    <meta charset="UTF-8">
</head>
<body>
<form action="fruit.html?act=list" method="post">
    分类：<select name="categoryId">
    <option value="">请选择</option>
    <c:forEach items="${categoryList}" var="cat">
        <option value="${cat.id}" ${param.categoryId==cat.id?'selected':''}>${cat.name}</option>
    </c:forEach>
</select>
    名称：<input type="text" name="name" value="${param.name}"/>
    id：<input type="text" name="id" value="${param.id}"/>
    <input type="submit" value="查询">
</form>
<table border="1">
    <tr>
        <td>id</td>
        <td>分类</td>
        <td>名称</td>
        <td>产地</td>
        <td>重量</td>
        <td>单价</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${fruitList}" var="fruit">
        <tr>
            <td>${fruit.id}</td>
            <td>${fruit.fruitCategory.name}</td>
            <td>${fruit.name}</td>
            <td>${fruit.place}</td>
            <td>${fruit.weight}KG</td>
            <td>${fruit.price/100}元</td>
            <td>
                <a href="fruit.html?act=detail&id=${fruit.id}">详情</a>
                <a href="#" onclick="del(${fruit.id})">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<script type="text/javascript">
    function del(id) {
        if (confirm("确定要删除吗？")) {
            window.location.href = "fruit.html?act=del&id=" + id;
        }
    }
</script>
</body>
</html>
